using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
public class BTAnim : Action
{
    private Animator animator;
    private Enemy enemy;
    public Animal.EnemyState state;

    public string[] boolNames;
    public bool[] boolValues;
    
    public string[] floatNames;
    public float[] floatValues;

    public string[] intNames;
    public int[] intValues;

    public string[] triggerNames;
    public bool[] triggerValues;
    
    public override void OnAwake()
    {
        base.OnAwake();
        animator = gameObject.GetComponent<Animator>();
        enemy = gameObject.GetComponent<Enemy>();
    }
    public override void OnStart()
    {
        base.OnStart();
        enemy.enemyState = state;
        for(int i = 0; i < boolNames.Length; i++)
        {
            bool flag;
            if(i>=boolValues.Length)flag=false;
            else flag=boolValues[i];
            animator.SetBool(boolNames[i], flag);
        }

        for (int i = 0; i < floatNames.Length; i++)
        {
            float f;
            if (i >= floatValues.Length) f = 0;
            else f = floatValues[i];
            animator.SetFloat(floatNames[i], f);
        }

        for (int i = 0; i < intNames.Length; i++)
        {
            int value;
            if (i >= intValues.Length) value = 0;
            else value = intValues[i];
            animator.SetInteger(intNames[i], value);
        }
        
        for (int i = 0; i < triggerNames.Length; i++)
        {
            bool flag;
            if (i >= triggerValues.Length) flag = false;
            else flag = triggerValues[i];
            if (flag) animator.SetTrigger(triggerNames[i]);
        }
    }
    
}
